package org.example.onlineEducation.utils;

import org.springframework.security.core.GrantedAuthority;

import java.util.Objects;

public class MyGrantedAuthority implements GrantedAuthority {

    private String authority;

    public MyGrantedAuthority(String authority){
        this.authority = authority;
    }

    public MyGrantedAuthority(){}

    @Override
    public String getAuthority() {
        return authority;
    }

    public void setAuthority(String authority){
        this.authority = authority;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o)
            return true;
        if (o == null || getClass() != o.getClass())
            return false;
        MyGrantedAuthority that = (MyGrantedAuthority) o;
        return this.authority.equals(that.authority);
    }

    @Override
    public int hashCode() {
        return Objects.hash(authority);
    }

    @Override
    public String toString() {
        return "MyGrantedAuthority{" +
                "authority='" + authority + '\'' +
                '}';
    }
}
